package com.biboheart.adapter.express.support;

import com.biboheart.adapter.express.operation.Calculate;
import com.biboheart.adapter.support.utils.ObjectTypeUtils;

final class BitInvCalculate implements Calculate<Number, Number, Number> {
    @Override
    public Number calc(Number left, Number right) {
        return calc(left);
    }

    @Override
    public Number calc(Number num) {
        if (null == num) {
            num = 0;
        }
        if (num instanceof Long) {
            return ~ObjectTypeUtils.convertType(num, Long.class);
        }
        return ~ObjectTypeUtils.convertType(num, Integer.class);
    }
}
